import { getLevelFirst, getLevelZero, getUserID } from '@/utils';

export const ManageTabSwitch = (curRes: Record<string, any>) => {
  if (curRes?.['/purchaseSourceExpertController/applyCompanyID']) {
    // 公司权限
    return {
      params: 'applyCompanyID',
      applyCompanyID: getLevelZero(),
    };
  } else if (curRes?.['/purchaseSourceExpertController/applyDepartmentID']) {
    return {
      params: 'applyDepartmentID',
      applyDepartmentID: getLevelFirst(),
    };
  } else if (curRes?.['/purchaseSourceExpertController/applyerID']) {
    return {
      params: 'applyerID',
      applyerID: getUserID(),
    };
  }
};

/** 采购计划Manage数据范围权限判断 */
export const sourceManageTab = (curRes: Record<string, any>) => {
  if (curRes?.['/purchaseSourceController/ownCompanyID']) {
    // 公司权限
    return {
      params: 'ownCompanyID',
      ownCompanyID: getLevelZero(),
    };
  } else if (curRes?.['/purchaseSourceController/ownDepartmentID']) {
    return {
      params: 'ownDepartmentID',
      ownDepartmentID: getLevelFirst(),
    };
  } else if (curRes?.['/purchaseSourceController/ownerID']) {
    return {
      params: 'ownerID',
      ownerID: getUserID(),
    };
  }
};

// 采购申请数据范围
export const ApplyManageTab = (curRes: Record<string, any>) => {
  if (curRes?.['/purchaseApplyController/applyCompanyID']) {
    return {
      applyCompanyID: getLevelZero(),
      params: 'applyCompanyID',
      key: 'ApplyManageTabKey',
    };
  } else if (curRes?.['/purchaseApplyController/applyDepartmentID']) {
    return {
      applyDepartmentID: getLevelFirst(),
      params: 'applyDepartmentID',
      key: 'ApplyManageTabKey',
    };
  } else if (curRes?.['/purchaseApplyController/applyerID']) {
    return {
      applyerID: getUserID(),
      params: 'applyerID',
      key: 'ApplyManageTabKey',
    };
  } else {
    return {};
  }
};
